﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entidad;
using Datos.EntityFramework;

namespace Datos.DAO
{
    //SRH
    public class CategoriaDAO
    {
        BD_HOTEL_Entities bd = new BD_HOTEL_Entities();
        public List<SRH_CATEGORIA> listarCategoria()
        {

            List<SRH_CATEGORIA> lista = new List<SRH_CATEGORIA>();
            try
            {
                var q = from c in bd.SRH_CATEGORIA
                        select c;
                lista = q.ToList();

            }
            catch (Exception)
            {
            }
            return lista;
        }



        public bool Insertar(SRH_CATEGORIA Obj)
        {
            try
            {
                bd.AddObject("SRH_CATEGORIA", Obj);
                bd.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }

        public bool Modificar(SRH_CATEGORIA obj)
        {
            try
            {
                bd.AttachTo("SRH_CATEGORIA", obj);
                bd.ObjectStateManager.ChangeObjectState(obj, System.Data.EntityState.Modified);
                bd.SaveChanges();
            }
            catch (Exception)
            {
                return false;

            }
            return true;
        }

        public bool Eliminar(SRH_CATEGORIA obj)
        {
            try
            {
                bd.AttachTo("SRH_CATEGORIA", obj);
                bd.DeleteObject(obj);
                bd.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
    }
}
